package com.skyz.wrap.manager;

import android.content.Context;
import android.text.TextUtils;

import com.skyz.base.util.SharedPreferenceUtils;
import com.skyz.wrap.utils.DateFormatUtils;

public class IndeDialogShowManager {

    private static final String KEY_INDE_DIALOG_SHOW = "INDE_DIALOG_SHOW";

    private IndeDialogShowManager() {
    }

    private static class InstanceHolder {
        private static final IndeDialogShowManager instance = new IndeDialogShowManager();
    }

    public static IndeDialogShowManager getInstance() {
        return InstanceHolder.instance;
    }

    public boolean canShow(Context context) {
        String saveDate = SharedPreferenceUtils.getStringValue(context, KEY_INDE_DIALOG_SHOW, "");
        if (TextUtils.isEmpty(saveDate)){
           return true;
        }
        long now = System.currentTimeMillis();
        String nowStr = DateFormatUtils.long2Str(now,false);
        return !saveDate.equals(nowStr);
    }

    public void show(Context context) {
        long now = System.currentTimeMillis();
        SharedPreferenceUtils.setValue(context, KEY_INDE_DIALOG_SHOW, DateFormatUtils.long2Str(now,false));
    }
}
